package bdz.common.utils {
	public class Drawing {
		public function Drawing(){
			  
		}
		public static function beginRadialGradientFill(colors:Array, alphas:Array, ratios:Array, centerPoint:Point, radius:Number, spreadMethod:String="pad", interpolationMethod:String="rgb"):void{   
		    var mat:Matrix = new Matrix();  
		    mat.createGradientBox(radius*2,radius*2,0,centerPoint.x-radius,centerPoint.y-radius);  
		    graphics.beginGradientFill(GradientType.RADIAL, colors, alphas, ratios, mat, spreadMethod, interpolationMethod);
		}  
			  
		public static function beginLinearGradientFill(colors:Array, alphas:Array, ratios:Array, startPoint:Point, endPoint:Point, spreadMethod:String="pad", interpolationMethod:String="rgb"):void{  
			var dx:Number = endPoint.x-startPoint.x;  
			var dy:Number = endPoint.y-startPoint.y;  
			var dist:Number = Math.sqrt(dx*dx+dy*dy);  
			var rad:Number = Math.atan2(dy,dx);  
			var offsetX:Number = -(dist - Math.cos(rad)*dist)*0.5 + startPoint.x;  
			var offsetY:Number = -(dist - Math.sin(rad)*dist)*0.5 + startPoint.y;  
			  
			var mat:Matrix = new Matrix();  
			mat.createGradientBox(dist,dist,rad,offsetX,offsetY);  
			graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, mat, spreadMethod, interpolationMethod);
		}
	}
}